//
//  TWLastTableViewCell.m
//  GOGOTravel
//
//  Created by dllo on 16/1/28.
//  Copyright © 2016年 果果. All rights reserved.
//

#import "TWLastTableViewCell.h"

@implementation TWLastTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
    }
    return self;
}

- (void)setModel:(Trip *)model{
    if (_model != model) {
        [_model release];
        _model = [model retain];
    }
    
    [self setValues];
}

- (void)setValues{
    _imageview1.image = [UIImage imageNamed:@"iconfont-camera_line.png"];
    
    _imageview2.image = [UIImage imageNamed:@"iconfont-1shijian.png"];
    
    _label.text = _model.name;
    NSString *str = [_model.date_added  substringToIndex:10];
    _label2.text = str;
}


- (void)awakeFromNib {
    // Initialization code
    if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"yeJianMoShi"] isEqualToString:@"isDay"]) {
        self.backgroundColor = DAYCOLOR;
    }else{
        self.backgroundColor = NIGHTCOLOR;
    }
    
    


[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeColor:) name:@"yeJianMoShi" object:nil];
}
- (void)changeColor:(NSNotification *)notification{
    
    if ([[[NSUserDefaults standardUserDefaults]objectForKey:@"yeJianMoShi"]isEqualToString:@"isNight"]) {
        self.backgroundColor = NIGHTCOLOR;
    }else{
        
        self.backgroundColor = DAYCOLOR;
    }
    
    
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)dealloc {
    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"changeColor" object:nil];
    [_imageview1 release];
    [_imageview2 release];
    [_label release];
    [_label2 release];
    [super dealloc];
}
@end
